package com.dq.domain.sys.user.user.centre;

import com.dq.domain.base.BaseEntity;
import com.dq.domain.org.Org;
import com.dq.domain.sys.section.SysSection;
import com.dq.domain.sys.user.user.WxUser;
import com.dq.utils.TimeUtil;
import com.dq.vo.baseVo.VO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author cf
 */
@Data
@Entity
@ApiModel("匿名信")
public class UserAnonymous extends BaseEntity implements VO.ToVO {
    @ApiModelProperty("所属门店")
    @ManyToOne
    protected SysSection section;

    @ApiModelProperty("内容")
    @Column(columnDefinition = "text")
    protected String details;


    @Data
    @ApiModel(value = "视图")
    public static class Vo implements VO {
        protected Long id;
        @ApiModelProperty(value = "所属店铺")
        private Long sectionId;
        private String sectionName;
        @ApiModelProperty(value = "创建人")
        private Long createUserId;
        private String createUserName;
        @ApiModelProperty("内容")
        protected String details;

        @ApiModelProperty(value = "创建时间")
        private String createTime;
    }
    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();
        vo.id = this.getId();
        vo.sectionId = this.getSection() == null ? null : this.getSection().getId();
        vo.sectionName = this.getSection() == null ? "" : this.getSection().getSimpleName();
        vo.createUserId = this.getCreateUser() == null ? null : this.getCreateUser().getId();
        vo.createUserName = this.getCreateUser() == null ? "" : this.getCreateUser().getUserRealcName();
        vo.details = fmt(this.getDetails());
        vo.createTime = fmt(this.getCreateTime(), TimeUtil.YYYY_MM_DD_HH_MM_SS);

        return vo;
    }
}
